package itbour.onetouchshow.activity.login;

import android.util.Log;

import com.google.gson.Gson;
import com.lsjr.callback.EncryBeanCallBack;
import com.lsjr.utils.HttpUtils;

import java.util.HashMap;
import java.util.List;

import itbour.onetouchshow.base.mvp.BasePresenterImpl;
import itbour.onetouchshow.bean.HomeDetailslBean;
import itbour.onetouchshow.constants.AppConfig;
import itbour.onetouchshow.constants.AppConst;
import itbour.onetouchshow.singlecase.InchingDataSingleCase;
import itbour.onetouchshow.utils.L_;
import itbour.onetouchshow.utils.SpUtils;

/**
 * Created by guoh on 2018/8/1.
 * 功能描述：
 * 需要的参数：
 */
public class SplashPresenter extends BasePresenterImpl<SplashView> {

    public void getHomeDetailsData() {
        L_.i("APP 基础信息  getHomeDetailsData===");
        HashMap<String, Object> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("device", 610);
        HttpUtils.getInstance().executeGet(AppConfig.GET_APPBASE_INFO_V10, stringStringHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {
                Log.e("tag", "" + exception);
                if (mvpView != null)
                    mvpView.loadFaild(exception);
            }

            @Override
            protected void onSuccess(String result) {
                L_.e("APP 基础信息  response===" + result);
                HomeDetailslBean appInfoBean;
                SpUtils.getInstance().saveString(AppConst.APPBASEINFO, result);
                appInfoBean = new Gson().fromJson(result, HomeDetailslBean.class);
                List<List<Integer>> colorList = appInfoBean.getColorList();
                List<HomeDetailslBean.FontListBean> fontList = appInfoBean.getFontList();
                HomeDetailslBean.TextConfigBean textConfig = appInfoBean.getTextConfig();
                HomeDetailslBean.AppControl appControl = appInfoBean.getAppControl();
                HomeDetailslBean.LengthControl lengthControl = appInfoBean.getLengthControl();

                InchingDataSingleCase.INSTANCE.setFontColorList(colorList);
                InchingDataSingleCase.INSTANCE.setFontTypeList(fontList);
                InchingDataSingleCase.INSTANCE.setTextConfig(textConfig);
                InchingDataSingleCase.INSTANCE.setAppControl(appControl);
                InchingDataSingleCase.INSTANCE.setLengthControl(lengthControl);
                if (mvpView != null)
                    mvpView.loadSucceed(result);
            }
        });
    }
}
